<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>getOut</title>
	<link href="../css/style.css" rel="stylesheet" type="text/css" />
	<link href="../css/form.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../js/registerForm.js"></script>
	<script type="text/javascript" src="../lib/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="../js/login_functions.js"></script>
	<script type="text/javascript" src="../js/addressValidation.js"></script>
</head>
<body>
<div class="rapidxwpr floatholder">
	<?php $activePage="none";  include_once "Header.php"; ?>
	<div id="middle">
	<div id="container" >
		<!-- form post logic -->
		<div id="error">
			<?php				
				if(isset($_POST['submit'])){
					if ($_POST['email'] == '' || $_POST['firstname'] == '' ||
						$_POST['lastname'] == '' || $_POST['city'] == '' ||
						$_POST['state'] == '' || $_POST['zip'] == '' ||
						$_POST['lat'] == 'error' ||  $_POST['long'] == 'error' ||
						$_POST['password'] == ''){
						echo("Registration failed!. Please make sure you enter all the required information");
					}
					else{
						$newUser = WebUser::WithParams(
							0,
							$_POST['email'],
							$_POST['firstname'] . " " . $_POST['lastname'],
							$_POST['city'],
							$_POST['state'],
							$_POST['zip']
							//$_FILES['avatar']
						);
						
						$result = $newUser->Save($_POST['lat'], $_POST['long'], $_POST['password']);
						if(is_string($result)){
							echo("Error:".$result);
						}
						else
							header( 'Location: RegisterSuccess.php' );
					}
				}
			?>
		</div>
		<form method="post" action="Register.php" enctype="multipart/form-data">
			<header id="header" class="info">
				<h2>Registration</h2>
			</header>
			<ul>
				<li>
					<label class="desc">
						Name
						<span class="req">*</span>
					</label>
					<span>
						<input name="firstname" type="text" class="field text fn" size="15"/>
						<label>First</label>
					</span>
					<span>
						<input name="lastname" type="text" class="field text ln" value="" size="15"/>
						<label>Last</label>
					</span>
				</li>
				<li>
					<label class="desc">
						Address 
						<span id="addrReq" class="req">*</span>
						<img id="loading" class="hide" src="../images/loading.gif">
					</label>
					<div>
						<span class="addr1">
							<input name="address" type="text" class="field text addr large"/>
							<label>Street Address</label>
							</br>
						</span></br>
						<span class="city">
							<input name="city" type="text" class="field text addr"/>
							<label>City</label>
						</span>
						<span class="state">
							<input name="state" type="text" maxlength="2" class="field text addr small">
							<label>State</label>
						</span>
						<span class="zip">
							<input name="zip" type="text" class="field text addr medsmall" maxlength="5"/>
							<label>Zip Code</label>
						</span>
						<input name="lat" type="hidden"/>
						<input name="long" type="hidden"/>
					</div>
				</li>
				<li>
					<label class="desc">
						Email
						<span class="req">*</span>
					</label>
					<div>
						<input name="email" type="email" class="field text large" maxlength="50"/> 
					</div>
				</li>
				<li>
					<label class="desc">
						Password
						<span class="req">*</span>
					</label>
					<div>
						<input name="password" type="password" class="field text" maxlength="25"/> 
					</div>
				</li>
				<li class="hide">
					<label class="desc">
						Avartar
					</label>
					<div>
						<input name="avatar" type="file" class="field large"/> 
					</div>
				</li>
				<li>
					<div>
						</br>
						<input name="submit" class="submit" type="submit" value="Submit"/>
						<label>
							* Required fields must be entered to continue
						</label>
					</div>
				</li>
			</ul>
		</form> 
		</div>
	</div>
</div>
<div class="rapidxwpr floatholder">
	<div id="footer" class="clearingfix">
		<ul class="footermenu">
			<li><a href="#">Events</a></li>
			<li><a href="#">Spots</a></li>
			<li><a href="#">Activities</a></li>
			<li><a href="#">About</a></li>
		</ul>
	</div>
</div>				
</body>
</html>
